/*
*  account.h - Account management structures
*  Copyright (c) 2005 Derek Ingrouville (dergro@users.sourceforge.net)
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU Library General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "account.h"

MsnAccount *
msn_account_new ()
{
    MsnAccount *acct = NULL;

    acct = g_new (MsnAccount, 1);

    acct->passport = NULL;
    acct->password = NULL;
    acct->nickname = NULL;

    acct->profile.kv = NULL;
    acct->profile.sid = NULL;
    acct->profile.mspauth = NULL;
    acct->profile.client_ip = NULL;
    acct->profile.client_port = 0;

    acct->status = OFFLINE;

    return acct;
}

void
msn_account_free (MsnAccount *acct)
{
    g_return_if_fail (acct != NULL);

	if (acct->passport != NULL)
        g_free (acct->passport);

    if (acct->password != NULL)
        g_free (acct->password);
   
    if (acct->nickname != NULL)
        g_free (acct->nickname);

    if (acct->profile.kv != NULL)
        g_free (acct->profile.kv);

    if (acct->profile.sid != NULL)
        g_free (acct->profile.sid);

    if (acct->profile.mspauth != NULL)
        g_free (acct->profile.mspauth);
    
    if (acct->profile.client_ip != NULL)
        g_free (acct->profile.mspauth);
    
    if (acct->profile.mspauth != NULL)
        g_free (acct->profile.mspauth);

    g_free (acct);

    return;
}

int
msn_account_set_passport (MsnAccount *acct, const char *passport)
{
    g_return_val_if_fail (acct != NULL, -1);
    g_return_val_if_fail (passport != NULL, -1);

    if (acct->passport != NULL)
        g_free (acct->passport);

    acct->passport = g_strdup (passport);

    return 0;
}

int
msn_account_set_password (MsnAccount *acct, const char *password)
{
    g_return_val_if_fail (acct != NULL, -1);
    g_return_val_if_fail (password != NULL, -1);

    if (acct->password != NULL)
        g_free (acct->password);

    acct->password = g_strdup (password);

    return 0;
}

int
msn_account_set_nickname (MsnAccount *acct, const char *name)
{
    g_return_val_if_fail (acct != NULL, -1);
    g_return_val_if_fail (name != NULL, -1);

    if (acct->nickname != NULL)
        g_free (acct->nickname);

    acct->nickname = g_strdup (name);

    return 0;
}

int
msn_account_set_profile (MsnAccount *acct, MsnMessage *profilemsg)
{
    /* TODO: implement this.. */
    return 0;
}
